package com.mycjj.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.mycjj.android.R;
import com.mycjj.android.util.Preferences;

public class SelectYuyueTypeActivity extends BaseActivity implements android.view.View.OnClickListener{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_select_yuyue_type);
		mActManager.pushActivity(YUYUE_KEY, this);
		init();
	}
	private TextView mTv_store_name,mTv_change_store_name;
	private View mRl_baoyang_item,mRl_weixiu_item;
	private String carId;
	private void init(){
		initHeader();
		Intent intent = getIntent();
		if(intent != null){
			carId = intent.getStringExtra("carId");
		}
		mTv_store_name = (TextView)findViewById(R.id.tv_store_name);
		mTv_change_store_name = (TextView)findViewById(R.id.tv_change_store_name);
		mTv_change_store_name.setOnClickListener(this);
	}
	private ImageView mHeaderLeftImageview;
	private Button mHeaderRightButton;
	private TextView mHeaderTitleTextView;
	private void initHeader(){
		mHeaderLeftImageview = (ImageView) findViewById(R.id.header_left_button);
		mHeaderLeftImageview.setImageResource(R.drawable.back);
		mHeaderRightButton = (Button) findViewById(R.id.header_right_button);
		mHeaderRightButton.setVisibility(View.GONE);
		mHeaderTitleTextView = (TextView) findViewById(R.id.header_title_textview);
		mHeaderTitleTextView.setText("选择预约类型");
		mHeaderLeftImageview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mActManager.popActivity(YUYUE_KEY,SelectYuyueTypeActivity.this);
			}
		});
		
		mRl_baoyang_item = findViewById(R.id.rl_baoyang_item);
		mRl_weixiu_item = findViewById(R.id.rl_weixiu_item);
		mRl_baoyang_item.setOnClickListener(this);
		mRl_weixiu_item.setOnClickListener(this);
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		mTv_store_name.setText(Preferences.getSharedPreferences(mApp, "storeName", "浙江奥同汽车有限公司"));
	}
	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.tv_change_store_name:
			Intent intent = new Intent(this, SelectStoreActivity.class);
			startActivity(intent);
			break;
		case R.id.rl_baoyang_item:
			jump2Store("2");
			break;
		case R.id.rl_weixiu_item:
			jump2Store("1");
			break;
		}
	}
	
	private void jump2Store(String arg){
		//跳转到4s店选择界面
		Intent intent = new Intent(this, SelectStoreActivity.class);
		intent.putExtra("type", arg);
		intent.putExtra("carId", carId);
		intent.putExtra("action", 1);
		startActivity(intent);
		
	}
	
	
}
